﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Warehouse.Core;
using Tanmia.Basis.Domain;
using Tanmia.Basis.Data;
using Tanmia.Basis;

namespace Tanmia.Warehouse.Domain
{
    public class SectionDomain : BaseDomain<Section>
    {
        public SectionDomain(ISessionManager sessionManager)
            : base(sessionManager)
        {
        }

        public IList<Section> GetsWithHead()
        {
            IList<Section> sections = Gets();
            sections.Insert(0, Section.HeadItem);
            return sections;
        }

        public IList<Section> GetParentSections(Branch branch)
        {
            return Repository.Gets(x => x.Branch.BranchID == branch.BranchID && x.Parent == null);
        }

        public IList<Section> GetChildSections(Section parent)
        {
            return Repository.Gets(x => x.Parent.SectionID == parent.SectionID);
        }
    }
}
